package com.gxuwz.service.impl;

import java.util.Date;

import com.gxuwz.entity.User;
import com.gxuwz.mapper.UserMapper;
import com.gxuwz.service.IUserService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;

import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 刘玉霜
 * @since 2017-10-27
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {

	@Autowired
	private UserMapper userDao;
	
	@Override
	public User login(User user) {	
		return userDao.selectByUsernameAndPassword(user);
	}
	
	@Override
	public Integer save(User user){
		user.setJoinTime(DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
		user.setType(1);
		return userDao.insert(user);
	}
	
}
